<?php

if (!isset($_SESSION['logged']))
    print "<script language='javascript'>
        window.location.href='./?url=404';
        </script>";
else {
    $idfile = $_POST['idfile'];
    $title = $_POST['title'];
    $idtype = $_POST['type'];
    $description = $_POST['description'];

    $linkfile = $_POST['link'];
    if (substr($linkfile, 0, 4) != "http") {
        $linkfile = "http://" . $linkfile;
    }

    $sql = "UPDATE `file` SET `title` = '$title', `type_id` = '$idtype', `description` = '$description', `link` = '$linkfile' WHERE `id` = '$idfile';";
    $result = mysql_query($sql, $link);

    print "<script language='javascript'>
        window.location.href='./';
        </script>";
}
?>
